package day17.zhiyou100;

import java.io.*;
import java.util.Arrays;

public class Demo05_InputStreamReader {
    public static void main(String[] args) throws Exception {
        /*File file = new File("D:\\aa\\bb\\ww.txt");
        // 创建文件字节输入流对象
        FileInputStream fis = new FileInputStream(file);
        // 创建转换输入流对象
        InputStreamReader isr = new InputStreamReader(fis,"gbk");
        char[] chars = new char[9];
        int read = isr.read(chars);
        System.out.println("读取到的字符个数为："+read);
        System.out.println(new String(chars));//*/

        // 一起使用转换输入流和转换输出流对象
        File input = new File("D:\\aa\\bb\\ww.txt");// gbk
        File out = new File("D:\\aa\\bb\\out.txt");// 编码字符集  utf-8
        FileInputStream fis = new FileInputStream(input);
        FileOutputStream fos = new FileOutputStream(out);
        // 再次创建转换流对象
        InputStreamReader isr = new InputStreamReader(fis,"gbk");

        OutputStreamWriter osw = new OutputStreamWriter(fos,"utf-8");
        // 边读边写
        int content;
        while ((content = isr.read()) != -1) {
            osw.write(content);
        }
        // 关闭流对象
        osw.close();
        isr.close();
        fos.close();
        fis.close();
    }



}
